Skip to content

fix: use POSIX normalize for remote Linux paths#2929

Merged
la14-1 merged 1 commit intoOpenRouterTeam:mainfrom
AhmedTMM:fix/posix-normalize-remote-path
Mar 24, 2026
Merged

fix: use POSIX normalize for remote Linux paths#2929
la14-1 merged 1 commit intoOpenRouterTeam:mainfrom
AhmedTMM:fix/posix-normalize-remote-path

Conversation

@AhmedTMM
Copy link
Collaborator

Summary

  • validateRemotePath() used normalize() from node:path which is platform-dependent — on Windows it converts / to \
  • Remote paths are always Linux paths (SSH/SCP to Linux VMs), so backslashes break the character allowlist and reject every valid path
  • Switched to node:path/posix so normalization always uses forward slashes regardless of client OS
  • Added 6 tests for validateRemotePath covering valid paths, POSIX normalization, traversal, empty, injection, and unsafe chars

Test plan

  • Biome lint passes (0 errors)
  • bun test src/__tests__/ssh-cov.test.ts passes (15/15, 6 new)
  • Manual: verify on Windows that spawn claude hetzner doesn't fail during config upload

🤖 Generated with Claude Code

Copy link
Member

@louisgv louisgv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security Review

Verdict: APPROVED
Commit: de28155

Findings

No security issues found. This PR is a security improvement.

SECURITY IMPROVEMENT (LOW): Fixes path normalization to use POSIX rules for remote Linux paths, preventing Windows hosts from sending malformed paths with backslashes to Linux servers.

Analysis

  • Changed node:pathnode:path/posix for normalize() to ensure consistent forward-slash paths
  • The existing validateRemotePath already blocks path traversal (..), argument injection (-), and unsafe characters (;, |, etc.)
  • POSIX normalize ensures no backslashes are introduced on Windows hosts
  • Comprehensive test coverage added for security validation (path traversal, injection, unsafe chars)

Tests

  • bun test: PASS (15 tests, 24 assertions)
  • biome lint: PASS (0 errors)
  • bash -n: N/A (no .sh files changed)
  • curl|bash: N/A (no remote execution changes)
  • macOS compat: N/A (TypeScript only)

-- security/pr-reviewer

node:path.normalize() is platform-dependent — on Windows it converts
forward slashes to backslashes, which then fail the character allowlist
regex. Remote paths are always Linux paths regardless of the client OS.

Switch to node:path/posix so normalization always uses forward slashes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@la14-1 la14-1 force-pushed the fix/posix-normalize-remote-path branch from de28155 to 08b80af Compare March 24, 2026 02:33
@la14-1 la14-1 merged commit 659fd1c into OpenRouterTeam:main Mar 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants